Analysis of 5 smFRET samples

In this notebook we perform background analysis for multi-spot measurements.

Load FRETBursts software


In [ ]:
from fretbursts import *

In [ ]:
import os
from IPython.display import display
%matplotlib inline

In [ ]:
from IPython.html.widgets import interact, interactive, fixed
from IPython.html import widgets
from IPython.display import display
from IPython.utils.traitlets import link

In [ ]:
import lmfit
print('lmfit version:', lmfit.__version__)

8-spot paper plot style


In [ ]:
PLOT_DIR = './figure/'

In [ ]:
import seaborn as sns
#%run -i styles/style.py
#np.set_printoptions(formatter={'float': lambda x: '%6.2f'%x})
import matplotlib as mpl

# brewer2mpl.get_map args: set name  set type  number of colors
#bmap = brewer2mpl.get_map('Set1', 'qualitative', 9)
bmap = sns.color_palette("Set1", 9)
colors = np.array(bmap)[(1,0,2,3,4,8,6,7), :]

In [ ]:
if mpl.__version__.startswith('1.4'):
    mpl.rcParams['axes.color_cycle'] = list(colors)    
else:
    # Version 1.5 or later
    from cycler import cycler
    mpl.rcParams['axes.prop_cycle'] = cycler('color', colors)

In [ ]:
colors_labels = ['blue', 'red', 'green', 'violet', 'orange', 'gray', 'brown', 'pink', ]
for c, cl in zip(colors, colors_labels):
    locals()[cl] = tuple(c) # assign variables with color names
sns.palplot(colors)

Data files

Data folder:


In [ ]:
data_dir = './data/multispot/'

Check that the folder exists:


In [ ]:
data_dir = os.path.abspath(data_dir) + '/'
assert os.path.exists(data_dir), "Path '%s' does not exist." % data_dir

List of data files in data_dir:


In [ ]:
from glob import glob
file_list = sorted(glob(data_dir + '*.hdf5'))

In [ ]:
labels = ['7d', '12d', '17d', '22d', '27d', 'DO']
files_dict = {lab: fname for lab, fname in zip(sorted(labels), file_list)}
files_dict

Parameters

Analysis parameters:


In [ ]:
## Background fit parameters
bg_kwargs_auto = dict(fun=bg.exp_fit,
                 time_s = 30,
                 tail_min_us = 'auto',
                 F_bg=1.7,
                 )

Processing and plot options:


In [ ]:
plt.rc('savefig', dpi=75)  # Changes the figure size in the notebook
savefig_kwargs =  dict(dpi=200, bbox_inches='tight')  # default save-figure options

5-samples processing

7bp sample


In [ ]:
data_id = '7d'
d7 = loader.photon_hdf5(files_dict[data_id])
d7.calc_bg(**bg_kwargs_auto)

In [ ]:
dplot(d7, timetrace_bg);
for period in range(d7.nperiods):
    dplot(d7, hist_bg, period=period, binwidth=50e-6, legend=False);
    plt.legend(bbox_to_anchor=(1, 1),
               bbox_transform=plt.gcf().transFigure)
    xlim(0, 6);

12bp sample


In [ ]:
data_id = '12d'
d12 = loader.photon_hdf5(files_dict[data_id])
d12.calc_bg_cache(**bg_kwargs_auto)

In [ ]:
dplot(d12, timetrace_bg);

In [ ]:
for period in range(d12.nperiods):
    dplot(d12, hist_bg, period=period, binwidth=50e-6, legend=False);
    plt.legend(bbox_to_anchor=(1, 1),
               bbox_transform=plt.gcf().transFigure)
    xlim(0, 6);

17bp sample


In [ ]:
data_id = '17d'
d17 = loader.photon_hdf5(files_dict[data_id])
d17.calc_bg_cache(**bg_kwargs_auto)

In [ ]:
dplot(d17, timetrace_bg);

In [ ]:
for period in range(d17.nperiods):
    dplot(d17, hist_bg, period=period, binwidth=50e-6, legend=False);
    plt.legend(bbox_to_anchor=(1, 1),
               bbox_transform=plt.gcf().transFigure)
    xlim(0, 6);

22bp sample


In [ ]:
data_id = '22d'
d22 = loader.photon_hdf5(files_dict[data_id])
d22.calc_bg_cache(**bg_kwargs_auto)

In [ ]:
dplot(d22, timetrace_bg);

In [ ]:
for period in range(d22.nperiods):
    dplot(d22, hist_bg, period=period, binwidth=50e-6, legend=False);
    plt.legend(bbox_to_anchor=(1, 1),
               bbox_transform=plt.gcf().transFigure)
    xlim(0, 6);

27bp sample


In [ ]:
data_id = '27d'
d27 = loader.photon_hdf5(files_dict[data_id])
d27.calc_bg_cache(**bg_kwargs_auto)

In [ ]:
dplot(d27, timetrace_bg);

In [ ]:
for period in range(d27.nperiods):
    dplot(d27, hist_bg, period=period, binwidth=50e-6, legend=False);
    plt.legend(bbox_to_anchor=(1, 1),
               bbox_transform=plt.gcf().transFigure)
    xlim(0, 6);

D-only sample


In [ ]:
data_id = 'DO'
do = loader.photon_hdf5(files_dict[data_id])
do.calc_bg_cache(**bg_kwargs_auto)

In [ ]:
dplot(do, timetrace_bg);

In [ ]:
for period in range(do.nperiods):
    dplot(do, hist_bg, period=period, binwidth=50e-6, legend=False);
    plt.legend(bbox_to_anchor=(1, 1),
               bbox_transform=plt.gcf().transFigure)
    xlim(0, 6);